package cn.tta.controller.admin;

import cn.tta.common.result.Result;
import cn.tta.pojo.vo.BusinessDataVO;
import cn.tta.service.WorkspaceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.time.LocalTime;

/**
 * 工作台
 */
@RestController
@RequestMapping("/admin/workspace")
public class WorkSpaceController {


    @Autowired
    private WorkspaceService workspaceService;


    @GetMapping("/overviewSetmeals")
    public Result setmealOverView() {
        return Result.success(workspaceService.getSetmealOverView());
    }

    /**
     * 查询菜品总览
     * @return
     */
    @GetMapping("/overviewDishes")
    public Result dishOverView() {
        return Result.success(workspaceService.getDishOverView());
    }

    /**
     * 查询订单管理数据
     * @return
     */
    @GetMapping("/overviewOrders")
    public Result orderOverView() {
        return Result.success(workspaceService.orderOverView());
    }

    /**
     * 工作台今日数据查询
     * @return
     */
    @GetMapping("/businessData")
    public Result businessData() {
        LocalDateTime begin = LocalDateTime.now().with(LocalTime.MIN);
        LocalDateTime end = LocalDateTime.now().with(LocalTime.MAX);
        BusinessDataVO businessDataVO = workspaceService.getBusinessData(begin,end);
        return Result.success(businessDataVO);
    }
}
